package mysrpringboot.springboot.loginInterceptor;




import mysrpringboot.springboot.Service.SellService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;

import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfiguration implements WebMvcConfigurer {

    @Autowired
    private SellService SellService;


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        int num = SellService.findNum();
        System.out.println(num);
        System.out.println("==============================="+"hahahahahaha");
        // 注册拦截器
        LoginInterceptor loginInterceptor = new LoginInterceptor();
        InterceptorRegistration loginRegistry = registry.addInterceptor(loginInterceptor);
        System.out.println("==============================="+loginRegistry);
        // 拦截路径
       loginRegistry.addPathPatterns("/**");
        // 排除路径
       // loginRegistry.excludePathPatterns("/");
        loginRegistry.excludePathPatterns("/login","/login.do");
        // 排除资源请求
        loginRegistry.excludePathPatterns("/css/login/*.css");
        loginRegistry.excludePathPatterns("/js/login/**/*.js");
        loginRegistry.excludePathPatterns("/image/login/*.png");
        loginRegistry.excludePathPatterns("/assets/**");
    }



}
